<?php

class Create_Mail_Accounts {

	/**
	 * Make changes to the database.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('mail_accounts', function($table){
            $table->increments('id');
            $table->string('localpart', 128);
            $table->string('password', 128);
            $table->integer('quota')->unsigned();
            $table->integer('domain_id')->unsigned();
            $table->foreign('domain_id')->references('id')
                        ->on('mail_domains')
                        ->on_delete('restrict')
                        ->on_update('cascade');
            $table->timestamps();
        });

        DB::query('ALTER TABLE mail_accounts MODIFY COLUMN quota BIGINT(20) NOT NULL;');
	}

	/**
	 * Revert the changes to the database.
	 *
	 * @return void
	 */
	public function down()
	{
        Schema::drop('mail_accounts');
	}

}
